package com.github.spy.apollo.squirrel.controller;

import com.github.spy.apollo.squirrel.service.OrderService;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * module name
 *
 * @author spy
 * @version 1.0 2020/8/20
 * @since 1.0
 */
@Slf4j
@RestController
@RequestMapping(value = "/order/")
public class OrderController {

    @Autowired
    OrderService orderService;

    @GetMapping(value = "submitOrder")
    public Map<Object, Object> submitOrder() {
        int orderId = orderService.submitOrder();
        return ImmutableMap.of("orderId", orderId);
    }

    @GetMapping(value = "pay")
    public Map<Object, Object> pay() {
        int orderId = orderService.pay();
        return ImmutableMap.of("orderId", orderId);
    }
}
